<template>
	<view>
		<view class="">
			<image class="imgs" src="/static/mine/bjj.png" mode="aspectFill"></image>
			<image class="imgs1" src="/static/mine/fx3.png" mode=""></image>
		</view>
		<uni-nav-bar background-color="" class="nav" statusBar :border="false" left-icon="back"
			@clickLeft="goback"></uni-nav-bar>
		<view class="content">
			<view class="inputs">
				<view class="input_top">
					<span>*</span>
					姓名
				</view>
				<view class="input_bot">
					<input v-model="params.name" type="text" placeholder="请输入你的姓名" />
				</view>
			</view>
			<view class="inputs">
				<view class="input_top">
					<span>*</span>
					手机号
				</view>
				<view class="input_bot">
					<input v-model="params.phone" type="number" maxlength="11" placeholder="请输入你的手机号" />
				</view>
			</view>
			<view class="inputs">
				<view class="input_top">
					<span>*</span>
					身份证号
				</view>
				<view class="input_bot">
					<input v-model="params.id_card" type="text" placeholder="请输入你的身份证号" />
				</view>
			</view>

			<!-- 		<view class="imglisrt">
				<view class="">
					<view class="text">
						<span>*</span>
						身份证正面
					</view>
					<imageUpload up-with="300" :imgList='imgList' @change="imgFn" maxCount="1"></imageUpload>
				</view>
				<view class="">
					<view class="text">
						<span>*</span>
						身份证国徽面
					</view>
					<imageUpload up-with="300" :imgList='imgList' @change="imgFn" maxCount="1"></imageUpload>
				</view>
			</view> -->
			<view class="inputs">
				<view class="input_top">
					<span>*</span>
					所在地区
				</view>
				<view class="input_bot">
					<region :citylist='citylist' @regionStr='regionchange'></region>
				</view>
			</view>
			<view class="inputs">
				<view class="input_top">
					<span>*</span>
					详细地址
				</view>
				<view class="input_bot">
					<input v-model="params.address" type="text" placeholder="请输入详细地址" />
				</view>
			</view>
			<view class="inputs">
				<view class="input_top">
					<span>*</span>
					开户行
				</view>
				<view class="input_bot">
					<input v-model="params.bank_name" type="text" placeholder="请输入真实开户行,可前往app查看" />
				</view>
			</view>
			<view class="inputs">
				<view class="input_top">
					<span>*</span>
					佣金结算卡号
				</view>
				<view class="input_bot">
					<input v-model="params.bank_card" type="text" placeholder="请输入你的结算卡号" />
				</view>
			</view>

			<!-- 	<view class="inputs">
				<view class="input_top">
					<span>*</span>
					银行卡照片
				</view>
				<imageUpload up-with="350" :imgList='imgList' @change="imgFn" maxCount="1"></imageUpload>
			</view> -->
			<view class="xy" @click="handlexy">
				<image v-if="isyes" src="/static/mine/xuan2.png" mode=""></image>
				<image v-else src="/static/mine/xuan1.png" mode=""></image>
				<view class="">
					我已阅读并同意<span @click.stop="goxieyi">分销协议</span>
				</view>
			</view>
		</view>
		<view class="" style="height: 10rpx;"></view>
		<view class="footerbtn" @click="handleSave">
			<view class="cont">
				<view class="btn">
					提交申请
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				citylist: [],
				imgList: [],
				params: {
					mid: '',
					name: '',
					id_card: '',
					address: '',
					bank_card: '',
					bank_name: '',
					phone: '',
				},
				addressList:[],
				isyes:false
			};
		},
		methods: {
			// 跳转协议
			goxieyi() {
				uni.navigateTo({
					url: '/minepage/xieyi'
				})
			},
			// imgFn(e) {
			// 	this.imgList = e
			// },
			regionchange(e) {
				console.log(e);
				this.addressList = e
			},
			goback() {
				uni.navigateBack()
			},
			handlexy(){
				this.isyes =!this.isyes
			},
			handleSave() {
				if (this.params.name == ''){
					uni.showToast({
						title:'请填写姓名',
						icon:'none'
					})
					return
				}
				if (this.params.phone == ''){
					uni.showToast({
						title:'请填写手机号',
						icon:'none'
					})
					return
				}
				if (this.params.id_card == ''){
					uni.showToast({
						title:'请填写身份证号',
						icon:'none'
					})
					return
				}
				if (this.addressList.length==0){
					uni.showToast({
						title:'请选择地区',
						icon:'none'
					})
					return
				}
				if (this.params.address == ''){
					uni.showToast({
						title:'请输入地址',
						icon:'none'
					})
					return
				}
				if (this.params.bank_name == ''){
					uni.showToast({
						title:'请填写开户行',
						icon:'none'
					})
					return
				}
				if (this.params.bank_card == ''){
					uni.showToast({
						title:'请填写卡号',
						icon:'none'
					})
					return
				}
				if (!this.isyes){
					uni.showToast({
						title:'查看并同意协议',
						icon:'none'
					})
					return
				}
				this.params.mid = uni.getStorageSync('msg').id
				this.params.address = this.addressList+'/'+this.params.address
				this.$post('distribution/apply',this.params).then(res => {
					if (res.code == 0) {
						uni.redirectTo({
							url:'/minepage/result'
						})
					}
				})
				
			}
		}
	}
</script>

<style lang="scss">
	page {
		background: #F8F8F8;
	}

	.nav {
		width: 100%;
		position: absolute;
		top: 0%;
		z-index: 9;
	}

	.imgs {
		width: 100%;
		height: 516rpx;
		position: relative;
	}

	.imgs1 {
		width: 690rpx;
		height: 320rpx;
		display: block;
		margin: -340rpx auto;
	}

	.content {
		margin: 360rpx auto 180rpx;
		width: 710rpx;
		background: #FFFFFF;
		border-radius: 20rpx 20rpx 20rpx 20rpx;
		padding: 30rpx 40rpx;
		box-sizing: border-box;

		.inputs {
			margin-bottom: 30rpx;

			.input_top {
				span {
					color: red;
				}

				font-family: PingFang SC,
				PingFang SC;
				font-weight: 500;
				font-size: 30rpx;
				color: #000000;
				margin-bottom: 20rpx;
			}

			.input_bot {
				width: 630rpx;
				height: 80rpx;
				background: #F8F8F8;
				border-radius: 12rpx 12rpx 12rpx 12rpx;
				line-height: 80rpx;

				input {
					line-height: 80rpx;
					height: 80rpx;
					padding-left: 20rpx;
					font-size: 28rpx;
				}
			}
		}

		.imglisrt {
			display: flex;
			justify-content: space-between;
			margin-bottom: 30rpx;

			.text {
				span {
					color: red;
				}

				font-family: PingFang SC,
				PingFang SC;
				font-weight: 500;
				font-size: 30rpx;
				color: #000000;
				margin-bottom: 20rpx;
			}
		}
	}

	.xy {
		display: flex;
		align-items: center;
		font-family: PingFang SC, PingFang SC;
		font-weight: 500;
		font-size: 24rpx;
		color: #D1D1D6;
		text-align: center;
		width: 320rpx;
		margin: 0 auto;

		span {
			color: #000;
			margin: 0 6rpx;
		}

		image {
			width: 30rpx;
			height: 30rpx;
			margin-right: 10rpx;
		}
	}

	.footerbtn {
		width: 750rpx;
		height: 100rpx;
		background: #FFFFFF;
		position: fixed;
		bottom: 0%;
		padding-bottom: constant(safe-area-inset-bottom);
		padding-bottom: env(safe-area-inset-bottom);
		z-index: 99;

		.cont {
			display: flex;
			padding: 10rpx 20rpx;
			height: 100rpx;
			font-family: PingFang SC, PingFang SC;
			font-weight: 500;
			font-size: 32rpx;
			align-items: center;
			justify-content: center;

			.btn {
				width: 670rpx;
				height: 80rpx;
				background: linear-gradient(133deg, #FE7444 0%, #FFA568 100%);
				border-radius: 8rpx 8rpx 8rpx 8rpx;
				color: #FFFFFF;
				font-family: PingFang SC, PingFang SC;
				font-weight: 500;
				font-size: 32rpx;
				line-height: 80rpx;
				text-align: center;
			}

			.absbtn {
				background: #808080;
			}
		}
	}
</style>